package com.lute.report;

import java.util.List;

import com.lute.model.EmployeeAccountingPeriod;

import net.sf.jasperreports.engine.JRDataSource;

public abstract class LuteAbstractFactoryReport {
	private String reportType;
	private String generatedOn;
	private String employee;
	private String position;
	private String client;
	private String businessUnit;
	private String accountingPeriod;
	
	public LuteAbstractFactoryReport() {}
	
	public LuteAbstractFactoryReport(String reportType, String generatedOn,
			                         EmployeeAccountingPeriod period, String from) {
		this.reportType = reportType;
		this.generatedOn = generatedOn;
		this.accountingPeriod = from;
		prepareBasicRaport(period);
	}
	
	public String getReportType() {
		return reportType;
	}

	public void setReportType(String reportType) {
		this.reportType = reportType;
	}

	public String getGeneratedOn() {
		return generatedOn;
	}

	public void setGeneratedOn(String generatedOn) {
		this.generatedOn = generatedOn;
	}

	public String getEmployee() {
		return employee;
	}

	public void setEmployee(String employee) {
		this.employee = employee;
	}

	public String getPosition() {
		return position;
	}

	public void setPosition(String position) {
		this.position = position;
	}

	public String getClient() {
		return client;
	}

	public void setClient(String client) {
		this.client = client;
	}

	public String getBusinessUnit() {
		return businessUnit;
	}

	public void setBusinessUnit(String businessUnit) {
		this.businessUnit = businessUnit;
	}

	public String getAccountingPeriod() {
		return accountingPeriod;
	}

	public void setAccountingPeriod(String accountingPeriod) {
		this.accountingPeriod = accountingPeriod;
	}
	
	public void prepareBasicRaport(EmployeeAccountingPeriod period) {
	
		if(period.getEmployee() == null) {
			this.employee = period.getApprover().getFirst_name()+ " " + period.getApprover().getLast_name(); 
			this.position = period.getApprover().getApproverProfile().getPositions().getName();
			this.client = period.getClientAccountingPeriod().getClient().getName();
			this.businessUnit = period.getApprover().getApproverProfile().getBusinessUnit().getName();
			
			
		} else {
			this.employee = period.getEmployee().getFirst_name()+ " " + period.getEmployee().getLast_name(); 
			this.position = period.getEmployee().getEmployeeProfil().getPositions().getName();
			this.client = period.getClientAccountingPeriod().getClient().getName();
			this.businessUnit = period.getEmployee().getEmployeeProfil().getBusinessUnit().getName();
			
		}
	}
	
	/* factory method */
	public abstract JRDataSource getDataSource(List<Integer> employeeIds, List<String> froms); 
}
